package boot.service.impl.wxGoods;

import boot.dao.GoodsMapper;
import boot.domain.wenchuang.Wenchuang;
import boot.domain.wenchuang.WenchuangExample;
import boot.domain.wxGoods.Goods;
import boot.domain.wxGoods.GoodsExample;
import boot.domain.wxGoodsCategory.GoodscategoryExample;
import boot.service.wxGoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class wxGoodServiceImpl implements wxGoodService {
    @Autowired
    private GoodsMapper goodsMapper;
    @Override
    public boolean addGood(Goods goods) {
        try {
            goodsMapper.insert(goods);
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
        return true;
    }

    @Override
    public List<Goods> getAllgoods() {
        GoodsExample goodsExample = new GoodsExample();
        GoodsExample.Criteria criteria = goodsExample.createCriteria();
        criteria.andIdIsNotNull();
        List<Goods> list = goodsMapper.selectByExample(goodsExample);
        System.out.println(list);
        return goodsMapper.selectByExample(goodsExample);
    }

    @Override
    public Goods getGoodById(int goodId) {
        Goods goods = goodsMapper.selectByPrimaryKey(goodId);
//        System.out.println(goods);
        return goods;
    }

}
